<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
        <ui:composition template="/templates/template.xhtml">
            <ui:define name="content">
                <b><h3><h:outputLabel value="Administrer oppgaver" rendered="#{user.findRole()}"/></h3></b>
                <b><h3><h:outputLabel value="Denne siden har du ikke tilgang til!" rendered="#{not user.findRole()}"/></h3></b>
                <br/>
                <h:form>
                <h:commandLink  action="../protected/chooseGame.xhtml" rendered="#{user.findRole()}">Tilbake</h:commandLink>
               <br/><br/><br/>
                <h:selectOneMenu value="#{tasks.chooseTaskType}" onchange="submit()">
                           <f:selectItem itemValue="1" itemLabel="Pluss" />
                           <f:selectItem itemValue="2" itemLabel="Minus" />
                           <f:selectItem itemValue="3" itemLabel="Gange" />
                           <f:selectItem itemValue="4" itemLabel="Dele" />
                       </h:selectOneMenu>
                </h:form>
                <br/>
                <h:form>
                    <h:dataTable value="#{tasks.tableTasksAdmin}" var="name" styleClass="names"
                                 headerClass="namesHeader" footerClass="namessFooter"
                                 rowClasses="last,first" rendered="#{user.findRole()}">
                        
                        <h:column>
                            <f:facet name="header">Oppgave nr.</f:facet>
                            <h:outputText value="#{name.taskId}" />
                        </h:column>

                        <h:column>
                            <f:facet name="header">Tekst</f:facet>
                            <h:outputText value="#{name.text}"/>
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">Vanskelighet</f:facet>
                            <h:outputText value="#{name.difficulty}" />
                        </h:column>

                        <h:column>
                            <f:facet name="header">Svar</f:facet>
                            <h:outputText value="#{name.answer}" />
                        </h:column>
                        
                        <h:column>
                            <h:commandLink action="../protected/changeTask.xhtml"  style="margin-left: 10px;">
                                <h:graphicImage value="/resources/images/edit.png" />
                                <f:setPropertyActionListener target="#{tasks.storeTask}" value="#{name}"/>
                            </h:commandLink>
                        </h:column>
                    </h:dataTable>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>